/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.bullionxpress.client.view;

import com.javadocking.DockingManager;
import com.javadocking.drag.DraggerFactory;
import com.javadocking.drag.StaticDraggerFactory;
import com.javadocking.drag.painter.CompositeDockableDragPainter;
import com.javadocking.drag.painter.DockableDragPainter;
import javax.swing.JRadioButtonMenuItem;

/**
     * A check box menu item to enable a dragger.
     */
    public class DraggingMenuItem extends JRadioButtonMenuItem {

        // Constructor.
        public DraggingMenuItem(String title, DockableDragPainter basicDockableDragPainter, DockableDragPainter additionalDockableDragPainter, boolean selected) {
            super(title);

            // Create the dockable drag painter and dragger factory.
            CompositeDockableDragPainter compositeDockableDragPainter = new CompositeDockableDragPainter();
            compositeDockableDragPainter.addPainter(basicDockableDragPainter);
            if (additionalDockableDragPainter != null) {
                compositeDockableDragPainter.addPainter(additionalDockableDragPainter);
            }
            DraggerFactory draggerFactory = new StaticDraggerFactory(compositeDockableDragPainter);

            // Give this dragger factory to the docking manager.
            if (selected) {
                DockingManager.setDraggerFactory(draggerFactory);
                setSelected(true);
            }

            // Add a dragging listener as action listener.
            addActionListener(new DraggingListener(draggerFactory));

        }
    }